package com.hst.capacity.infra.convertor;

import com.hst.capacity.domain.model.entity.order.express.ExpressOrderEntity;
import com.hst.capacity.domain.model.entity.order.express.ExpressOrderHistoryEntity;
import com.hst.capacity.domain.model.entity.order.express.ExpressOrderOperationHistory;
import com.hst.capacity.domain.model.entity.order.express.ExpressOrderResultEntity;
import com.hst.capacity.domain.model.entity.order.intercity.IntercityOrderEntity;
import com.hst.capacity.domain.model.entity.order.intercity.IntercityOrderHistoryEntity;
import com.hst.capacity.domain.model.entity.order.intercity.IntercityOrderOperationHistory;
import com.hst.capacity.domain.model.entity.order.intercity.IntercityOrderResultEntity;
import com.hst.capacity.domain.model.entity.order.pool.OrderPoolEntity;
import com.hst.capacity.domain.model.entity.order.specialcar.SpCarOrderEntity;
import com.hst.capacity.domain.model.entity.order.specialcar.SpCarOrderHistoryEntity;
import com.hst.capacity.domain.model.entity.order.specialcar.SpCarOrderOperationHistory;
import com.hst.capacity.domain.model.entity.order.specialcar.SpCarOrderResultEntity;
import com.hst.capacity.domain.model.request.OrderForDispatchParam;
import com.hst.capacity.domain.model.request.OrderParam;
import com.hst.capacity.domain.model.request.dispatcher.DispatcherOrderParam;
import com.hst.capacity.domain.model.request.dispatcher.DispatcherSearchOrderParam;
import com.hst.capacity.domain.model.request.elong.order.ElongOrderParam;
import com.hst.capacity.domain.model.request.express.ExListParam;
import com.hst.capacity.domain.model.request.express.ExpressCreateOrderParam;
import com.hst.capacity.domain.model.request.intercity.IcListParam;
import com.hst.capacity.domain.model.request.intercity.IntercityCreateOrderParam;
import com.hst.capacity.domain.model.request.price.ExpressStpPriceParam;
import com.hst.capacity.domain.model.request.price.IntercityPriceParam;
import com.hst.capacity.domain.model.request.price.PriceParam;
import com.hst.capacity.domain.model.request.specialcar.SpListParam;
import com.hst.capacity.domain.model.response.order.OrderDetailVO;
import com.hst.capacity.domain.model.response.order.OrderOperationLogVO;
import com.hst.capacity.domain.model.response.order.OrderVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface OrderConvertor {

    OrderConvertor INSTANCE = Mappers.getMapper(OrderConvertor.class);

    OrderVO exOrderToView(ExpressOrderEntity entity);
    List<OrderVO> exOrderLstToView(List<ExpressOrderEntity> list);
    OrderVO icOrderToView(IntercityOrderEntity entity);
    List<OrderVO> icOrderLstToView(List<IntercityOrderEntity> list);
    OrderVO spOrderToView(SpCarOrderEntity entity);
    List<OrderVO> spOrderLstToView(List<SpCarOrderEntity> list);

    PriceParam convertExPriceParam(ExpressOrderEntity entity);
    ExpressStpPriceParam convertExStpPriceParam(ExpressOrderEntity entity);
    IntercityPriceParam convertIcPriceParam(IntercityOrderEntity entity);
    PriceParam convertSpPriceParam(SpCarOrderEntity entity);


    @Mapping(target="appointmentTime", dateFormat="yyyy-MM-dd HH:mm")
    @Mapping(target="assignTime", dateFormat="yyyy-MM-dd HH:mm")
    @Mapping(target="deptime", dateFormat="yyyy-MM-dd HH:mm")
    @Mapping(target="desttime", dateFormat="yyyy-MM-dd HH:mm")
    @Mapping(target="startServiceTime", dateFormat="yyyy-MM-dd HH:mm")
    @Mapping(target="endServiceTime", dateFormat="yyyy-MM-dd HH:mm")
        //@Mapping(target = "idStation", source = "idRailwayStation")
    OrderVO orderPoolToView(OrderPoolEntity entity);
    List<OrderVO> orderPoolLstToView(List<OrderPoolEntity> list);
    //ExpressOrderStatusHistoryEntity exOrderStatusConvert();

    ExpressOrderResultEntity exOrderReslutConvert(OrderParam param);
    ExpressOrderResultEntity exOrderReslutConvert(ExpressCreateOrderParam param);

    IntercityOrderResultEntity icOrderReslutConvert(OrderParam param);
    IntercityOrderResultEntity icOrderReslutConvert(IntercityCreateOrderParam param);

    SpCarOrderResultEntity spOrderReslutConvert(OrderParam param);

    ExpressOrderEntity convertToHistory(ExpressOrderHistoryEntity param);
    IntercityOrderEntity convertToHistory(IntercityOrderHistoryEntity param);
    SpCarOrderEntity convertToHistory(SpCarOrderHistoryEntity param);

    OrderDetailVO convertToOrderDetail(ExpressOrderEntity param);
    OrderDetailVO convertToOrderDetail(IntercityOrderEntity param);
    OrderDetailVO convertToOrderDetail(OrderPoolEntity param);

//    @Mapping(target = "opTime", source = "createTime")
//    @Mapping(target = "operator", source = "createBy")
//    @Mapping(target = "reason", source = "operation")
    @Mapping(target="createTime", dateFormat="yyyy-MM-dd HH:mm")
    List<OrderOperationLogVO> convertToOrderLogList(List<SpCarOrderOperationHistory> list);
    @Mapping(target="createTime", dateFormat="yyyy-MM-dd HH:mm")
    List<OrderOperationLogVO> convertToOrderLogListEx(List<ExpressOrderOperationHistory> list);
    @Mapping(target="createTime", dateFormat="yyyy-MM-dd HH:mm")
    List<OrderOperationLogVO> convertToOrderLogListIc(List<IntercityOrderOperationHistory> list);

    OrderParam convert2Param(ElongOrderParam param);
    OrderForDispatchParam convert2Param(DispatcherOrderParam param);
    SpListParam convert2SpParam(DispatcherSearchOrderParam param);
    ExListParam convert2ExParam(DispatcherSearchOrderParam param);
    IcListParam convert2IcParam(DispatcherSearchOrderParam param);

}
